<!DOCTYPE html>
<html>
  <head>
    <title>登录</title>
    <link href="/stylesheets/style.css" rel="stylesheet" />
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>
  <body>
    <div>
      <ul>
        <li><a href="/test/">Test</a></li>
        <li><a class="active" href="login">立即登录</a</li>
        <li><a href="logout">退出登录</a></li>
        <li><a href="regist">立即注册</a></li>
      </ul>
    </div>      
    <div class="form-box">
      <form id="form">
          <input type="text"  name="username"  placeholder="请输入用户名">
          <input type="password" name="password"  placeholder="请输入密码">
          <input type="button"  onclick="mySubmit()" value="登录">
      </form>
      <div>没有帐号， <a href="/regist">立即注册</a></div>
  </div>
   
    
  </body>
  <script>
    function mySubmit(){ 
      let formData = new FormData(document.getElementById('form'));
      let data = Object.fromEntries(formData.entries());
      axios.post('/test/setToken',data).then((res)=>{
        console.log(res.data);
        localStorage.setItem("token", res.data.token);
		    alert('提交成功！');
      });
    }
 </script>
</html>